package com.clkj.aimin.dao.user;

import com.clkj.aimin.pojo.user.UserRegister;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author yawang
 * @create 2024/04/03 18:31:12
 **/
@Repository
public interface UserRegisterMapper extends Mapper<UserRegister> {

    @Select("select a.*,b.doctor_name,c.department_name  from t_cl_userRegister a " +
            "left join t_cl_doctor b on a.doctor_id =b.doctor_id " +
            "left join t_cl_department c on a.department_id = c.department_id " +
            "where a.user_id = #{userId} order by a.register_id desc ")
    List<UserRegister> listUserRegister(@Param("userId")Integer userId);

    @Select("select a.*,b.user_name from t_cl_userRegister a " +
            "left join t_cl_user b on a.user_id = b.user_id " +
            "where a.doctor_id = #{doctorId} and datediff(MINUTE,getdate(),(register_date+' '+time_slot)) >=0")
    List<UserRegister> listUserRegisterByDoctor(@Param("doctorId")Integer doctorId);

    @Select("select * from t_cl_userRegister where doctor_id = #{doctorId} and datediff(day,register_date,getDate()) = 0 ")
    List<UserRegister> listRegister(@Param("doctorId")Integer doctorId);

}
